package model.os;

import java.util.ArrayList;
import java.util.List;


import controller.Application;

public class Scheduler {
	
	private List<OSProcess> processes;
	
	public Scheduler() {
		processes = new ArrayList<OSProcess>();
	}

	public void add(OSProcess process) {
		processes.add(process);
	}
	
	public void runAllProcesses() {
		for (Thread process : processes) {
			process.start();
		}
	}
	
	public void stopAll() {
		for (OSProcess process : processes) {
			PageTable pageTable = OS.getInstance().getPageTable(process);
			for (PageTableEntry entry : pageTable.getEntries().values()) {
				entry.setValid(false);
			}
		}
	}
	
	public void clear(){
		processes.clear();
	}
	
	public List<OSProcess> getProcesses(){
		return processes;
	}
	
}
